<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
?>
<script type="text/javaScript"><!--//--><![CDATA[//><!--

function editAdmExam() {

	if(document.EditSkill.title=='Save') {
		editAdminExam();
		return;
	}

	var frm=document.frmEmp;
	for (var i=0; i < frm.elements.length; i++)
	frm.elements[i].disabled = false;

	document.EditSkill.src="../../themes/beyondT/pictures/btn_save.gif";
	document.EditSkill.title="Save";
}


function addAdminExam() {

	if(document.frmEmp.cmbAdmExamId.value=='0') {
		alert("必须选择等级津贴");
		document.frmEmp.cmbAdmExamId.focus();
		return;
	}

	document.frmEmp.examSTAT.value="ADD";
	qCombo(23);
}

function decimal(txt) {
	regExp = /^[0-9]+(\.[0-9]+){0,1}$/;

	if (regExp.test(txt)) {
		return true;
	}

	return false;
}

function editAdminExam() {
	if(document.frmEmp.cmbAdmExamId.value=='0') {
		alert("必须选择等级津贴");
		document.frmEmp.cmbAdmExamId.focus();
		return;
	}
	document.frmEmp.examSTAT.value="EDIT";
	qCombo(23);
}

function delEmpAdminExam() {

	var check = false;
	with (document.frmEmp) {
		for (var i=0; i < elements.length; i++) {
			if ((elements[i].name == 'chkempexamdel[]') && (elements[i].checked == true)) {
				check = true;
			}
		}
	}

	if(!check) {
		alert('<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>')
		return;
	}

	document.frmEmp.examSTAT.value="DEL";
	qCombo(23);
}

function viewAdminExam(exm_id) {
	document.frmEmp.action = document.frmEmp.action + "&ADM_EXM=" + exm_id;
	document.frmEmp.pane.value = 23;
	document.frmEmp.submit();
}

function getExamSalary(exm_id) {
	if(exm_id==0) document.frmEmp.txtExamSalary.value = 0;
	else {
		var data = eval(<?php echo json_encode($this->popArr['uexamlist']);?>)
		for (var i=0; i < data.length; i++) {
			if(data[i][0]==exm_id) {
				document.frmEmp.txtExamSalary.value = data[i][2];
				break;
			}
		}
	}
}
//--><!]]></script>
<div id="parentPaneSkills" >
<?php if(isset($this->getArr['capturemode']) && $this->getArr['capturemode'] == 'updatemode') { ?>
<input type="hidden" name="examSTAT" value=""/>
<?php
if(isset($this->popArr['editAdmExamArr'])) {
	$edit = $this->popArr['editAdmExamArr'];
	?>
	<div id="editPaneAdminExam" >

	<table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
	<tr>
                      <td width="200">等级津贴</td>
    				  <td><input type="hidden" name="cmbAdmExamId" value="<?php echo $edit[0][1]?>"/><strong>
<?php						$allExamList = $this->popArr['allExamList'];
						for($c=0;count($allExamList)>$c;$c++)
							if($this->getArr['ADM_EXM']==$allExamList[$c][0])
							     break;

					  	echo $allExamList[$c][1];
?>
					  </strong></td>
					</tr>
					
	<tr>
                      <td>等级津贴加薪(元)</td>
    				  <td><input type="text" name="txtExamSalary" id="txtExamSalary" value="<?php echo isset($this->popArr['txtExamSalary']) ? $this->popArr['txtExamSalary'] : $allExamList[$c][2]?>" readonly/></td>
    				  <td width="50">&nbsp;</td>
					  </tr>

	<tr>
	<td><?php echo $lang_Leave_Common_Comments?></td>
	<td> <textarea rows="3" cols="25" name="txtEmpExamComments"><?php echo isset($this->popArr['txtEmpExamComments']) ? $this->popArr['txtEmpExamComments'] : $edit[0][2]?></textarea></td>
	<td width="50">&nbsp;</td>
	</tr>
	</table>
	<?php	if($locRights['edit']) { ?>
	<div class="formbuttons">
	<!--input type='hidden' name='examId' value='<?php echo $edit[0][0];?>' /-->
	<input type="button" class="savebutton" name="btnEditAdmExam" id="btnEditAdmExam"
	value="<?php echo $lang_Common_Save;?>"
	title="<?php echo $lang_Common_Save;?>"
	onmouseover="moverButton(this);" onmouseout="moutButton(this);"
	onclick="editAdminExam(); return false;"/>
	<input type="reset" class="resetbutton" value="<?php echo $lang_Common_Reset; ?>" />
	</div>
	<?php	} ?>
	</div>
	<?php } else { ?>
	<div id="addPaneAdminExam" class="<?php echo ($this->popArr['rsetSkill'] != null)?"addPane":""; ?>" >
	<table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
	<tr>
                      <td width="200">等级津贴</td>
                      <?php
                      		$examlist = $this->popArr['uexamlist'];
                      		//$alwlistjson = json_encode($skillalwlist);
                      ?>
    				  <td><select name="cmbAdmExamId" <?php echo $locRights['add'] ? '':'disabled="disabled"'?> onChange="getExamSalary(this.value)">
    				  		<option selected="selected" value="0">-----------选择等级津贴-------------</option>
<?php
						for($c=0;$examlist && count($examlist)>$c;$c++)
							   echo "<option value='" . $examlist[$c][0] . "'>" . $examlist[$c][1] . "</option>";
?>
					  </select></td>
					</tr>
	<tr>
	<td>等级津贴加薪(元)</td>
	<td><input type="text" name="txtExamSalary" <?php echo $locRights['add'] ? '':'disabled="disabled"'?> value="<?php echo isset($this->popArr['txtExamSalary']) ? $this->popArr['txtExamSalary'] :''?>" readonly/></td>
	<td width="50">&nbsp;</td>
	</tr>
	<tr>
	<td><?php echo $lang_Leave_Common_Comments?></td>
	<td> <textarea <?php echo $locRights['add'] ? '':'disabled="disabled"'?> rows="3" cols="25" name="txtEmpExamComments"><?php echo isset($this->popArr['txtEmpExamComments']) ? $this->popArr['txtEmpExamComments'] :''?></textarea></td>
	<td width="50">&nbsp;</td>
	</tr>
	<tr>
	<td valign="top"></td>
	<td align="left" valign="top">
	</td>
	</tr>
	</table>
	<?php	if($locRights['add']) { ?>
	<div class="formbuttons">
	<input type="button" class="savebutton" name="btnAddAdmExam" id="btnAddAdmExam"
	value="<?php echo $lang_Common_Save;?>"
	title="<?php echo $lang_Common_Save;?>"
	onmouseover="moverButton(this);" onmouseout="moutButton(this);"
	onclick="addAdminExam(); return false;"/>
	<input type="reset" class="resetbutton" value="<?php echo $lang_Common_Reset; ?>" />
	</div>
	<?php	} ?>
	</div>
	<?php } ?>
	<?php
	$rset = $this->popArr['rsetAdmExam'] ;
	$allEmpExamList = $this->popArr['allEmpExamList'];

	if ($rset != null){ ?>
	<div class="subHeading"><h3>添加等级津贴</h3></div>

	<div class="actionbar">
	<div class="actionbuttons">
	<?php if ($locRights['add']) { ?>
	<input type="button" class="addbutton"
	onclick="showAddPane('adminExam');" onmouseover="moverButton(this);" onmouseout="moutButton(this);"
	value="<?php echo $lang_Common_Add;?>" title="<?php echo $lang_Common_Add;?>"/>
	<?php } ?>
	<?php	if ($locRights['delete']) { ?>
	<input type="button" class="delbutton"
	onclick="delEmpAdminExam();" onmouseover="moverButton(this);" onmouseout="moutButton(this);"
	value="<?php echo $lang_Common_Delete;?>" title="<?php echo $lang_Common_Delete;?>"/>

	<?php 	} ?>
	</div>
	</div>

	<table width="100%" cellspacing="0" cellpadding="0" class="data-table">
	<thead>
	<tr>
	<td></td>
	<td>等级津贴</td>
	<td>等级津贴加薪(元)</td>
	<td>注释</td>
	</tr>
	</thead>
	<tbody>
	<?php
	//$rset[$c][4] 为等级津贴主键ID
	for($c=0; $rset && $c < count($rset); $c++) {
		$cssClass = ($c%2) ? 'even' : 'odd';
    	echo '<tr class="' . $cssClass . '">';

            echo "<td><input type='checkbox' class='checkbox' name='chkempexamdel[]' value='" . $rset[$c][1] ."'/></td>";

			for($a=0;count($allEmpExamList)>$a;$a++)
				if($rset[$c][1] == $allEmpExamList[$a][0]) {
				   $lname = $allEmpExamList[$a][2];
				   $lsalary = $allEmpExamList[$a][1];
				}
			?><td><a href="javascript:viewAdminExam('<?php echo $rset[$c][1]?>')"><?php echo $lname?></a></td><?php
			echo '<td>'. $lsalary .'</td>';
			echo '<td>'. $rset[$c][2] .'</td>';

        echo '</tr>';
    }

	?>
	</tbody>
	</table>
	<?php } ?>
	<?php } ?>
	</div>